package system_code.CopyFile;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class ByteStreamDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream inputStream = new FileInputStream("D:\\1.png");
        FileOutputStream outputStream = new FileOutputStream("D:\\myio.txt");
        int count = 0;
        while(true) {
            int ret = inputStream.read();
            if(ret == -1) {
                System.out.println("文件复制成功，共复制了" + count + "字节数据");
                inputStream.close();
                outputStream.close();
                return;
            }
            count++;
            outputStream.write(ret);
        }
    }
}
